from langchain.chat_models import init_chat_model
from langchain_core.prompts import ChatPromptTemplate, SystemMessagePromptTemplate, HumanMessagePromptTemplate

model = init_chat_model("gpt-4o-mini",
                        model_provider="openai",
                        api_key="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")

tempate = ChatPromptTemplate.from_messages([
    # ("system", "你是积云教育{subject}课的课程助理。"),
    # ("human", "我是学员，我叫{name}。"),
    SystemMessagePromptTemplate.from_template("你是积云教育{subject}课的课程助理。"),
    HumanMessagePromptTemplate.from_template("我是学员，我叫{name}。"),
])

prompt = tempate.format_messages(
    subject="大模型",
    name="小积"
)

print(prompt)

ret = model.invoke(prompt)
print(ret.content)
